/*
 * Random.c
 *
 *  Created on: Jan 21, 2013
 *      Author: Ian Smith, Travis Drake
 */
#include "random.h"
#include <stdlib.h>
#include <time.h>

static int initialized = 0;

/*
 * Gets a random number value between 0 (inclusive) and max_value (exclusive).
 * int random_number(int max_value);
 * max_value: the exclusive upper-bound of the number to be returned.
 */
int random_number(int max_value)
{
	if (!initialized)
	{
		srand(time(NULL));
		initialized = 1;
	}
	
	return rand() % max_value;
}

unsigned short random_reg_value(void)
{
	if (!initialized)
	{
		srand(time(NULL));
		initialized = 1;
	}

	return (unsigned short)rand();
}

Byte random_byte(void)
{
	if (!initialized)
	{
		srand(time(NULL));
		initialized = 1;
	}

	return (Byte)rand();
}
